import { DataTypes, Model } from 'sequelize';
import sequelize from '../db';

/**
 * 套餐权限关联模型
 */
class PlanPermission extends Model {
  public id!: string;
  public planId!: string;
  public permissionId!: string;
  public readonly createdAt!: Date;
  public readonly updatedAt!: Date;
}

PlanPermission.init(
  {
    id: {
      type: DataTypes.UUID,
      defaultValue: DataTypes.UUIDV4,
      primaryKey: true,
    },
    planId: {
      type: DataTypes.UUID,
      allowNull: false,
      field: 'plan_id',
    },
    permissionId: {
      type: DataTypes.UUID,
      allowNull: false,
      field: 'permission_id',
    },
  },
  {
    sequelize,
    tableName: 'plan_permissions',
    underscored: true,
    timestamps: true,
  },
);

export default PlanPermission;

